<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="ja" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta http-equiv="Content-Style-Type" content="text/css">
<!-- meta -->
<meta name="keywords" content="">
<meta name="description" content="">
<!-- /meta -->
<title>${gamenName} メタデータスキーマ登録</title>

<!-- JQuery 用 -->
<link href="<%= request.getContextPath() %>/common/css/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="<%= request.getContextPath() %>/common/js/jquery-1.4.4.min.js" type="text/javascript"></script>
<script src="<%= request.getContextPath() %>/common/js/jquery-ui-1.8.9.custom.min.js" type="text/javascript"></script>
<script src="<%= request.getContextPath() %>/common/js/jquery.cookie.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/common/css/base.css">
<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/common/css/headerfooter.css">
<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/common/css/ulol.css">
<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/common/css/arrow.css">
<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/common/css/elements.css">
<!-- admin -->
<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/common/css/base_admin.css">
<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/common/css/elements_admin.css">
<!-- /admin -->
<script type="text/javascript" src="<%= request.getContextPath() %>/common/js/library.js"></script>
<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/common/css/for_winie3.css">
<!--[if gte IE 5]>
<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/common/css/for_over_winie5.css">
<![endif]-->
<!--[if IE 5]>
<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/common/css/for_winie5.css">
<![endif]-->
<SCRIPT type="text/javascript">

	//入力形式編集Open
	function popupCreateInput(editIndex, inputType, optionKbn, options){


		 var url = '<%= request.getContextPath() %>/outputschema/popupCreateInputItem';

		 $('#createInputEditIndex').val(editIndex);
		 $('#createInputInputType').val(inputType);
		 $('#createInputOptionKbn').val(optionKbn);
		 $('#createInputOptionResult').val(options);

		 openByPost( url, $('#createInput').clone(), "createInput" );
	}
	//スキーマ新規追加
	function popCustomSchemaAdd() {

		 var url = '<%= request.getContextPath() %>/outputschema/popupCustomSchema';
		window.open(url,'child1', 'width=650, height=600, menubar=no, toolbar=no, scrollbars=yes');

	}
	//スキーマ編集
	function popCustomSchemaEdit(editIndex, itemName, inputType, optionKbn, optionResult) {

		 $('#customSchemaEditInfoItemName').val(itemName);
		 $('#customSchemaEditInfoEditIndex').val(editIndex);
		 $('#customSchemaEditInfoInputType').val(inputType);
		 $('#customSchemaEditInfooOtionKbn').val(optionKbn);
		 $('#customSchemaEditInfoOptionResult').val(optionResult);
		 var url = '<%= request.getContextPath() %>/outputschema/popupCustomSchema-edit';

		 openByPost( url, $('#customSchemaEditInfo').clone(), "customSchemaEdit" );

	}
	//入力形式編集
	function editInputType(editIndex, type, optionKbn, optionResult) {

		document.getElementById("editIndexId").value = editIndex;
		document.getElementById("typeId").value = type;
		document.getElementById("optionKbnId").value = optionKbn;
		document.getElementById("optionResultId").value = optionResult;
		addForm.action ='<%= request.getContextPath() %>/outputschema/manage-editInputType';
		addForm.submit();
	}

	//カスタムスキーマ編集
	function editCustomSchema(editIndex, itemName, inputType, optionKbn, optionResult) {

		document.getElementById("customEditIndexId").value = editIndex;
		document.getElementById("customItemNameId").value = itemName;
		document.getElementById("customInputTypeId").value = inputType;
		document.getElementById("customOptionKbnId").value = optionKbn;
		document.getElementById("customOptionResultId").value = optionResult;

		addForm.action ='<%= request.getContextPath() %>/outputschema/manage-editCustomSchema';
		addForm.submit();
	}
	//カスタムスキーマ追加
	function addCustomSchema(itemName, inputType, optionKbn, optionResult) {

		document.getElementById("customItemNameId").value = itemName;
		document.getElementById("customInputTypeId").value = inputType;
		document.getElementById("customOptionKbnId").value = optionKbn;
		document.getElementById("customOptionResultId").value = optionResult;

		addForm.action ='<%= request.getContextPath() %>/outputschema/manage-addCustomSchema';
		addForm.submit();
	}
	//カスタムスキーマ削除
	function doDeleteRow(editIndex) {
		document.getElementById("customEditIndexId").value = editIndex;
		addForm.action ='<%= request.getContextPath() %>/outputschema/manage-deleteCustomSchema';
		addForm.submit();
	}

	//親選択Open
	function popupOyaSelectOpen(sort) {
		 var url = '<%= request.getContextPath() %>/outputschema/popupOyaSelect?sort=' + sort;
		 window.open(url,'popupSearch', 'width=650, height=600, menubar=no, toolbar=no, scrollbars=yes');
	}
	function popupOyaSelect(oyaschemaid) {
		document.getElementById("selectOyaid").value = oyaschemaid;
		addForm.action ='<%= request.getContextPath() %>/outputschema/manage-selectoya';
		addForm.submit();
	}
	//親削除
	function deleteParentData() {
		document.getElementById('upperRank').innerHTML = "";
	}


</SCRIPT>
</head>
<body id="dch" >

<div id = "createInput" style="display:none" >
	<input type="hidden" name="editIndex" id = "createInputEditIndex" />
	<input type="hidden" name="type" id = "createInputInputType" />
	<input type="hidden" name="optionKbn" id = "createInputOptionKbn"/>
	<input type="hidden" name="optionResult" id = "createInputOptionResult"/>
</div>

<div id = "customSchemaEditInfo" style="display:none" >
	<input type="hidden" name="itemName" id = "customSchemaEditInfoItemName" />
	<input type="hidden" name="editIndex" id = "customSchemaEditInfoEditIndex" />
	<input type="hidden" name="inputType" id = "customSchemaEditInfoInputType" />
	<input type="hidden" name="optionKbn" id = "customSchemaEditInfooOtionKbn"/>
	<input type="hidden" name="optionResult" id = "customSchemaEditInfoOptionResult"/>
</div>

<!-- === headerArea === -->
<div id="headerArea">
<a name="pageTop" id="pageTop"></a>
<jsp:include page="/common/include/header.jsp" />
</div><!-- === /headerArea === -->
<!-- === mainArea === -->
<div id="mainArea">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
	<tr valign="top">
		<td width="140" id="leftArea">
			<jsp:include page="output_menu.jsp" />
			<!-- /listA01 -->
		</td>
		<td width="20"><img src="<%= request.getContextPath() %>/common/images/spacer.gif" width="20" height="4" border="0" alt=""></td>
		<td id="contentsArea">
		<!-- === contentsArea === -->
			<!-- headingLv01Block -->
			<div class="headingLv01Block">
				<!-- headingLv01 -->
				<h1>${gamenName} メタデータスキーマ登録</h1>
				<!-- /headingLv01 -->
			</div>
			<!-- /headingLv01Block -->
			<!-- columnB01 -->
			<div class="columnB01">
			 <s:fielderror/>
			 <s:actionerror/>
			 <s:actionmessage/>
			</div>
			<!-- /columnB01 -->
			<!-- headingLv02 -->
			<div class="headingLv02">
			<table border="0" cellspacing="0" cellpadding="5" width="558">
				<tr>
					<td><p><em>${gamenName} - ヘッダー</em></p></td>
				</tr>
			</table>
			</div>
			<!-- /headingLv02 -->
			<form action="<%= request.getContextPath() %>/outputschema/manage-confirm" method="post" id="addForm" name="addForm">

			<s:hidden name="actionType"/>
			<s:hidden name="sort"/>
			<s:hidden name="oyaSort"/>

		    <!-- ヘッダ情報 -->
		    <s:hidden name="dataSchema.sort"/>
		    <s:hidden name="dataSchema.schemaid"/>
			<s:hidden name="dataSchema.createUser"/>
			<s:hidden name="dataSchema.createDate"/>
			<s:hidden name="dataSchema.modifyUser"/>
			<s:hidden name="dataSchema.modifyDate"/>

			<!-- 入力形式編集情報 -->
			<s:hidden name="editIndex" id = "editIndexId" />
			<s:hidden name="type" id = "typeId"/>
			<s:hidden name="optionKbn" id = "optionKbnId"/>
			<s:hidden name="optionResult" id = "optionResultId"/>

			<!-- カスタムメタデータスキーマ入力情報 -->
			<s:hidden name="customEditIndex" id = "customEditIndexId" />
			<s:hidden name="customItemName" id = "customItemNameId"/>
			<s:hidden name="customInputType" id = "customInputTypeId"/>
			<s:hidden name="customOptionKbn" id = "customOptionKbnId"/>
			<s:hidden name="customOptionResult" id = "customOptionResultId"/>

			<!-- 選択した親ID -->
			<s:hidden name="selectOyaid" id = "selectOyaid" />

			<!-- tableBlock -->
			<div class="tableBlock">
				<!-- tableA01 -->
				<div class="tableA01">
				<table border="1" cellspacing="0" cellpadding="5" width="558">
					<tr>
						<!-- ラベル -->
						<th class="lv01B" width="170"><label for="name">メタデータスキーマ名称</label></th>
						<!-- エラー -->
						<th width="11" class="error">&nbsp;</th>
						<!-- 内容 -->
						<td><s:textfield name="dataSchema.name" size="35" cssErrorStyle="background-color: #FFE4E1"/></td>
					</tr>
					<c:if test="${sort != '001' and sort != '007'}">
					<tr>
						<!-- ラベル -->
						<th class="lv01B" width="170"><label for="fServiceName">${gamenOyaName}</label></th>
						<!-- エラー -->
						<th width="11" class="error">&nbsp;</th>
						<!-- 内容 -->
						<td><input type="button" value="選択" style="width: 100px" onclick="popupOyaSelectOpen('${oyaSort}')"><p>
				    		<c:if test="${dataSchema.oyaschemaid != null and dataSchema.oyaschemaid != ''}">
				    			<div id="upperRank">
				    			<table id="linkTable" width="100%">
			    					<tr>
					    				<td  width="80%">
					    					<s:property value="%{dataSchema.oyaschemaName}"/>
					    					<s:hidden name="dataSchema.oyaschemaid" />
					    					<s:hidden name="dataSchema.oyaschemaName" />
					    				<td width="20%"><input type="button" value="削除" onclick="deleteParentData()"></td>
			    					</tr>
				    			</table>
				    			</div>
				    		</c:if>
						</td>
					</tr>
					</c:if>
					<tr>
						<!-- ラベル --><th class="lv01B" width="170"><label for="createUser">登録者</label></th>
						<!-- エラー --><th width="11" class="error">&nbsp;</th>
						<!-- 内容 --><td><s:property value="%{dataSchema.createUser}" /></td>
					</tr>
					<tr>
						<!-- ラベル --><th class="lv01B" width="170"><label for="createDate">登録日付</label></th>
						<!-- エラー --><th width="11" class="error">&nbsp;</th>
						<!-- 内容 --><td><s:property value="%{dataSchema.createDate}" /></td>
					</tr>
					<tr>
						<!-- ラベル --><th class="lv01B" width="170"><label for="modifyUser">最終更新者</label></th>
						<!-- エラー --><th width="11" class="error">&nbsp;</th>
						<!-- 内容 --><td><s:property value="%{dataSchema.modifyUser}" /></td>
					</tr>
					<tr>
						<!-- ラベル --><th class="lv01B" width="170"><label for="modifyDate">最終更新日付</label></th>
						<!-- エラー --><th width="11" class="error">&nbsp;</th>
						<!-- 内容 --><td><s:property value="%{dataSchema.modifyDate}" /></td>
					</tr>
				</table>
				</div>
				<!-- /tableA01 -->
			</div>
			<!-- /tableBlock -->

			<!-- headingLv02 -->
			<div class="headingLv02">
			<table border="0" cellspacing="0" cellpadding="5" width="558">
				<tr>
					<td><p><em>メタデースキーマ情報 - ${gamenName}</em></p></td>
				</tr>
			</table>
			</div>
			<!-- /headingLv02 -->

			<div class="tableBlock">
				<!-- tableA01 -->
				<div class="tableA01">
					<table border="1" cellspacing="0" cellpadding="5" id="metaTbl">
						<tr>
							<th class="lv01B" colspan="3">項目</th>
							<th class="lv01B" colspan="2">入力形式</th>
							<th class="lv01B">要/不要</th>
							<th class="lv01B">TM<BR/>対応</th>
							<th class="lv01B">選択/必須</th>
							<th class="lv01B">PORTA連携</th>
							<th class="lv01B">コメント</th>
						</tr>
						<s:iterator value="define.list" status="stat">
						<tr>
							<!-- Fieldキー宣言 -->
							<s:set name="fieldKey" value="%{define.list[#stat.index].key}"/>
							<s:set name="dataSchemaDetail" value="%{getDataSchemaDetailByFieldKey(#fieldKey)}"/>

							<s:hidden name="schemaItemList[%{#stat.index}].fieldKey" value="%{#fieldKey}"/>
							<s:hidden name="schemaItemList[%{#stat.index}].schemaid" />

							<s:iterator value="itemList" status="itemStat">
								<th class="lv01B" rowspan="${rowspan}" colspan="${colspan}"><s:property value="value" /></th>
							</s:iterator>
							<td>
								<c:if test="${dataSchemaDetail.inputType == '0'}" >
									<span id="type1">テキスト</span>
							 		<s:hidden name="schemaItemList[%{#stat.index}].inputType"   value="%{#dataSchemaDetail.inputType}" />
								</c:if>
								<c:if test="${dataSchemaDetail.inputType == '1'}" >
									<span id="type1">テキストエリア</span>
							 		<s:hidden name="schemaItemList[%{#stat.index}].inputType" value="%{#dataSchemaDetail.inputType}" />
								</c:if>
								<c:if test="${dataSchemaDetail.inputType == '2'}" >
									<span id="type1">ドロップダウンリスト</span>
							 		<s:hidden name="schemaItemList[%{#stat.index}].inputType" value="%{#dataSchemaDetail.inputType}" />
								</c:if>
								<c:if test="${dataSchemaDetail.inputType == '3'}" >
									<span id="type1">ラジオボタン</span>
							 		<s:hidden name="schemaItemList[%{#stat.index}].inputType" value="%{#dataSchemaDetail.inputType}" />
								</c:if>
								<c:if test="${dataSchemaDetail.inputType == '4'}" >
									<span id="type1">チェックボックス</span>
							 		<s:hidden name="schemaItemList[%{#stat.index}].inputType" value="%{#dataSchemaDetail.inputType}" />
								</c:if>
								<c:if test="${dataSchemaDetail.inputType == '5'}" >
									<span id="type1">日付</span>
							 		<s:hidden name="schemaItemList[%{#stat.index}].inputType" value="%{#dataSchemaDetail.inputType}" />
								</c:if>
								<c:if test="${dataSchemaDetail.inputType == '6'}" >
									<span id="type1">複数テキスト</span>
							 		<s:hidden name="schemaItemList[%{#stat.index}].inputType" value="%{#dataSchemaDetail.inputType}" />
								</c:if>
								<c:if test="${dataSchemaDetail.inputType == '7'}" >
									<span id="type1">フィールド指定</span>
							 		<s:hidden name="schemaItemList[%{#stat.index}].inputType" value="%{#dataSchemaDetail.inputType}" />
								</c:if>
							 	<s:hidden name="schemaItemList[%{#stat.index}].optionKbn"  value="%{#dataSchemaDetail.optionKbn}" />
							 	<s:hidden name="schemaItemList[%{#stat.index}].options"  value="%{#dataSchemaDetail.options}" />
							 </td>
							 <td>
							 	<input type="button" value="編集" onclick="popupCreateInput('${stat.index}','${dataSchemaDetail.inputType}','${dataSchemaDetail.optionKbn}','<s:property value="%{#dataSchemaDetail.options}" escape="false" escapeJavaScript="true"/>')">
							 </td>
							 <td>
							 	<s:select list="#{'0':'要','1':'不要'}" name="schemaItemList[%{#stat.index}].display" value="%{#dataSchemaDetail.display}" />
							 </td>
							 <td align="center">
							 	<s:checkbox name="schemaItemList[%{#stat.index}].tmSign"  value="%{#dataSchemaDetail.tmSign}" />
							 </td>
							 <td>
							 	<s:select list="#{'0':'選択','1':'必須'}" name="schemaItemList[%{#stat.index}].hissuSelectSign"  value="%{#dataSchemaDetail.hissuSelectSign}" />
							 </td>
							 <td align="center">
							 	<s:checkbox name="schemaItemList[%{#stat.index}].portaSign"  value="%{#dataSchemaDetail.portaSign}" />
							 </td>
							 <td>
							 	<s:textarea name="schemaItemList[%{#stat.index}].content" rows="2" cols="35"  value="%{#dataSchemaDetail.content}" />
							 </td>
							<s:hidden name="schemaItemList[%{#stat.index}].customSign"  value="0"/>
						</tr>
						</s:iterator>
					</table>
					</div>
				<!-- /tableA01 -->
			</div>
			<!-- headingLv02 -->
			<div class="headingLv02">
			<table border="0" cellspacing="0" cellpadding="5" width="558">
				<tr>
					<td><p><em>メタデースキーマ情報 - カスタムメタデータスキーマ</em></p></td>
					<td><div class="tableBtn">
						<p><input type="button" value="新規追加する" onclick="popCustomSchemaAdd()"></p>
						</div></td>
				</tr>
			</table>
			</div>
			<!-- /headingLv02 -->
				<div class="tableBlock">
				<!-- tableA01 -->
				<div class="tableA01">
				<table border="1" cellspacing="0" cellpadding="5" id="customTagTbl">
					<tr>
						<th class="lv01B">処理</th>
						<th class="lv01B">項目</th>
						<th class="lv01B">入力形式</th>
						<th class="lv01B">要/不要</th>
						<th class="lv01B">TM<BR/>対応</th>
						<th class="lv01B">選択/必須</th>
						<th class="lv01B">PORTA連携</th>
						<th class="lv01B">コメント</th>
					</tr>
					<s:iterator value="customItemList" status="customItemStat">
					<tr>
						<td>
							<input type="button" value="編集" onclick="popCustomSchemaEdit('<s:property value="#customItemStat.index" escape="false" escapeJavaScript="true"/>',
																						'<s:property value="%{customItemList[#customItemStat.index].fieldItemName}" escape="false" escapeJavaScript="true"/>',
																						'<s:property value="%{customItemList[#customItemStat.index].inputType}" escape="false" escapeJavaScript="true"/>',
																						'<s:property value="%{customItemList[#customItemStat.index].optionKbn}" escape="false" escapeJavaScript="true"/>',
																						'<s:property value="%{customItemList[#customItemStat.index].options}" escape="false" escapeJavaScript="true"/>')"/>
							<input type="button" value="削除" onclick="doDeleteRow('${customItemStat.index}');"/>
						</td>
						<td>
							<c:out value="${fieldItemName}" />
							<s:hidden name="customItemList[%{#customItemStat.index}].fieldDisplayname" />
							<s:hidden name="customItemList[%{#customItemStat.index}].fieldItemName"/>

						</td>
						<td>
							<c:if test="${customItemList[customItemStat.index].inputType == '0'}" >
								<span id="type1">テキスト</span>
							 	<s:hidden name="customItemList[%{#customItemStat.index}].inputType" />
							</c:if>
							<c:if test="${customItemList[customItemStat.index].inputType == '1'}" >
								<span id="type1">テキストエリア</span>
						 		<s:hidden name="customItemList[%{#customItemStat.index}].inputType"/>
							</c:if>
							<c:if test="${customItemList[customItemStat.index].inputType == '2'}" >
								<span id="type1">ドロップダウンリスト</span>
						 		<s:hidden name="customItemList[%{#customItemStat.index}].inputType"/>
							</c:if>
							<c:if test="${customItemList[customItemStat.index].inputType == '3'}" >
								<span id="type1">ラジオボタン</span>
						 		<s:hidden name="customItemList[%{#customItemStat.index}].inputType"/>
							</c:if>
							<c:if test="${customItemList[customItemStat.index].inputType == '4'}" >
								<span id="type1">チェックボックス</span>
						 		<s:hidden name="customItemList[%{#customItemStat.index}].inputType"/>
							</c:if>
							<c:if test="${customItemList[customItemStat.index].inputType == '5'}" >
								<span id="type1">日付</span>
						 		<s:hidden name="customItemList[%{#customItemStat.index}].inputType"/>
							</c:if>
							<c:if test="${customItemList[customItemStat.index].inputType == '6'}" >
								<span id="type1">複数テキスト</span>
						 		<s:hidden name="customItemList[%{#customItemStat.index}].inputType"/>
							</c:if>
							<c:if test="${customItemList[customItemStat.index].inputType == '7'}" >
								<span id="type1">フィールド指定</span>
						 		<s:hidden name="customItemList[%{#customItemStat.index}].inputType"/>
							</c:if>
							<c:if test="${customItemList[customItemStat.index].inputType == '' || customItemList[customItemStat.index].inputType == null}" >
								<span id="type1">テキスト</span>
						 		<s:hidden name="customItemList[%{#customItemStat.index}].inputType" value="0"/>
							</c:if>

							<s:hidden name="customItemList[%{#customItemStat.index}].optionKbn" />
							<s:hidden name="customItemList[%{#customItemStat.index}].options" />
						</td>
						<td><s:select list="#{'0':'要','1':'不要'}" name="customItemList[%{#customItemStat.index}].display"  /></td>
						<td>
							<s:checkbox name="customItemList[%{#customItemStat.index}].tmSign" />
						</td>
						<td><s:select list="#{'0':'選択','1':'必須'}" name="customItemList[%{#customItemStat.index}].hissuSelectSign" /></td>
						<td align="center">
							 <s:checkbox name="customItemList[%{#customItemStat.index}].portaSign"/>
						</td>
						<td><s:textarea name="customItemList[%{#customItemStat.index}].content" rows="2" cols="35"/></td>
					</tr>
					<s:hidden name="customItemList[%{#customItemStat.index}].schemaid" />
					<s:hidden name="customItemList[%{#customItemStat.index}].fieldKey"  />
					<s:hidden name="customItemList[%{#customItemStat.index}].fieldDisplayOrder"  value="%{#customItemStat.index}"/>
					<s:hidden name="customItemList[%{#customItemStat.index}].customSign"  value="1"/>
					</s:iterator>
				</table>
			</div>
			</div>
			<!-- pageNaviC01 -->
			<div class="pageNaviC01">
			<table border="0" cellspacing="0" cellpadding="10" width="558">
				<tr>
					<td width="298" class="left"><p><input type="button" value="キャンセル" style="width:100px" onclick="location.href='<%= request.getContextPath() %>/output/modoru'"></p></td>
					<td width="130" class="left">&nbsp;</td>
					<td width="130" class="right"><p><input type="submit" value="確認する" style="width:130px"></p></td>
				</tr>
			</table>
			</div>
			<!-- /pageNaviC01 -->
			</form>
		<!-- === /contentsArea === -->
		</td>
		<td width="16"><img src="<%= request.getContextPath() %>/common/images/spacer.gif" width="16" height="4" border="0" alt=""></td>
	</tr>
</table>
</div><!-- === /mainArea === -->
<!-- === footerArea === -->
<div id="footerArea">
<jsp:include page="/common/include/footer.jsp" />
</div><!-- === /footerArea === -->
</body>
</html>
<!-- System Architect is COOBA Corp
	Copyright 2010 COOBA Corp All rights reserved -->